#import "ZHGIFToastManager.h"
#import "MBProgressHUD+BCHelper.h"
#import <BCFoundation/UIImage+BCGIF.h>

@implementation ZHGIFToastManager
///MARK: - 显示提示框 ProgressHUD
+ (MBProgressHUD *)showGifHud {
   return [self showGifHud:@"bc_screen_loading"];
}

+ (MBProgressHUD *)showGifHud:(NSString * _Nullable)gifName {
    return [self showGifHud:gifName toView:nil];
}

+ (MBProgressHUD *)showGifHud:(NSString * _Nullable)gifName toView:(UIView * _Nullable)view {
    if (view == nil){
        view = [[UIApplication sharedApplication].delegate window];
    }
     [self.class hideHud:view];
     MBProgressHUD* hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    UIImage *gifImage = [UIImage bc_animatedGIFNamed:gifName];
    UIImageView *gifImageView = [[UIImageView alloc]initWithImage:gifImage];
    hud.mode = MBProgressHUDModeCustomView;
    hud.removeFromSuperViewOnHide = YES;
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.backgroundColor = [UIColor clearColor];
    hud.contentColor = [UIColor blackColor];
    hud.customView = gifImageView;
    hud.backgroundColor = [UIColor whiteColor];
    
    return hud;
}
///MARK: - 隐藏提示框 ProgressHUD
+ (void)hideHud
{
    [[self class] hideHud:nil];
}
+ (void)hideHud:(UIView *)view
{
    if (view == nil){
        view = [[UIApplication sharedApplication].delegate window];
    }
    [MBProgressHUD bc_hideHUDForView:view animated:YES];
}
@end
